package com.itheima.service;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface UserService {
    /**
     * 查询所有用户
     */
    @Transactional(readOnly = true)
    public List<User> findAll();

    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Transactional(readOnly = true)
    public PageInfo<User> findByPage(int currentPage, int pageSize);

    /**
     * 根据用户id查询用户
     */
    @Transactional(readOnly = true)
    public User findById(Integer id);

    /**
     * 添加用户
     */
    public int save(User user);

    /**
     * 修改用户信息
     */
    public  int update(User user);


    /**
     * 根据id删除用户
     */

    public int delteById(Integer id);


    /**
     * 根据用户名和密码验证用户是否存在
     * @param username
     * @param password
     * @return
     */
    @Transactional(readOnly = true)
    public  User findUserByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

}
